package org.smile.design.proxy.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class Jarnvid implements MethodInterceptor {
    private Object target;

    public Jarnvid(Object target){
        this.target = target;
    }

    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println(o.getClass());
        System.out.println(method.toString());
        System.out.println(methodProxy.toString());

        System.out.println("method before");
        Object result = method.invoke(target, objects);
        System.out.println("method after");
        if (result instanceof Ship)
            System.out.println("yes yes yes");
        return result;
    }
}
